//
//  CarouselViewController.m
//  TotalDemo
//
//  Created by gujian on 16/5/13.
//  Copyright © 2016年 gujian. All rights reserved.
//

#import "CarouselViewController.h"
#import "CarouselView.h"
#import "CarouseView2.h"

@interface CarouselViewController ()

@property (nonatomic, weak) UIView *rotationView;

@end

@implementation CarouselViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"旋转木马";
    [self setCarousView];
    [self setRightBar];
}

- (void)setRightBar
{
    UIBarButtonItem *rightBarButtomItem = [[UIBarButtonItem alloc] initWithTitle:@"开始" style:UIBarButtonItemStylePlain target:self action:@selector(rightAction:)];
    self.navigationItem.rightBarButtonItem = rightBarButtomItem;
    
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(20, 330, 80, 80)];
//    view1.backgroundColor = [UIColor randomColor];
    [self.view addSubview:view1];
    _rotationView = view1;
}

- (void)rightAction:(id)sender
{
    CATransform3D transform = _rotationView.layer.transform;
    
    [UIView animateWithDuration:4.0 animations:^{
        _rotationView.layer.transform = CATransform3DMakeRotation(M_PI/3.0, 0, 0.5, 0);
    } completion:^(BOOL finished) {
        _rotationView.layer.transform = transform;
    }];
}

- (void)setCarousView
{
    CarouselView *carouselView = [[CarouselView alloc] initWithFrame:CGRectMake(0, 30, SCREEN_WIDTH, 140)];
    [self.view addSubview:carouselView];
    
    CarouseView2 *carousView2 = [[CarouseView2 alloc] initWithFrame:CGRectMake(0, 190, SCREEN_WIDTH, 120)];
    [self.view addSubview:carousView2];
    
    
//    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(20, 330, 80, 80)];
//    view1.backgroundColor = [UIColor randomColor];
//    [self.view addSubview:view1];
//    
//    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(view1.right+20, 330, 80, 80)];
//    view2.layer.transform = CATransform3DMakeRotation(M_PI/3.0, 0.5, 0, 0);
//    view2.backgroundColor = [UIColor randomColor];
//    [self.view addSubview:view2];
//    
//    UIView *view3 = [[UIView alloc] initWithFrame:CGRectMake(view2.right+20, 330, 80, 80)];
//    view3.layer.transform = CATransform3DMakeRotation(M_PI/3.0, 0, 0.5, 0);
//    view3.backgroundColor = [UIColor randomColor];
//    [self.view addSubview:view3];
    
}



@end
